package invoiceManager;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

public class InvoiceBatch{
	
	private ArrayList<Invoice> batch;
	private File invoiceFile;
	
	public InvoiceBatch(File invFile) throws FileNotFoundException{
		invoiceFile = invFile;
		batch = new ArrayList<Invoice>();
		
		Scanner scan = new Scanner(invFile);
		scan.useDelimiter("BEGIN");
		scan.next();
		while(scan.hasNext()){
			Invoice invoice  = new Invoice (scan.next());
			batch.add(invoice);
		}
		scan.close();
	}
	
	public String toString(){
		String ret = new String();
		for(Invoice i : batch){
			ret = ret + i.getCustomerID() +" "+ i.getBillLineOne() + " " + i.getInvoiceNumber()+ " " + i.getTotal() + "\n";
		}
		return ret;
	}

	public ArrayList<Invoice> getBatch() {
		return batch;
	}

	public void setBatch(ArrayList<Invoice> batch) {
		this.batch = batch;
	}

	public File getInvoiceFile() {
		return invoiceFile;
	}

	public void setInvoiceFile(File invoiceFile) {
		this.invoiceFile = invoiceFile;
	}

}
